
package com.kugou.game.sdk.ui.dialog;

import com.kugou.framework.base.BaseDialog;
import com.kugou.game.sdk.utils.Rx;

import android.app.Activity;
import android.util.DisplayMetrics;
import android.view.Gravity;
import android.view.View;
import android.view.ViewGroup;
import android.view.WindowManager;
import android.widget.TextView;

public class ModifyUserPhotoDialog extends BaseDialog {

    private TextView tvTakePhoto, tvAlbum, tvCancel;

    private View.OnClickListener onTakePhotoListener, onAlbumListener,
            onCancelModifyListener;

    public ModifyUserPhotoDialog(Activity activity) {
        this(activity, Rx.style.kg_KYTheme_Widget_Dialog);

    }

    public ModifyUserPhotoDialog(Activity activity, int theme) {
        super(activity, theme);
        setCanceledOnTouchOutside(true);
        setContentView(Rx.layout.kg_dialog_modify_user_photo);

        WindowManager.LayoutParams lp = getWindow().getAttributes();
        DisplayMetrics dm = new DisplayMetrics();
        activity.getWindowManager().getDefaultDisplay().getMetrics(dm);
        int parentWidth = dm.widthPixels;
        int width = parentWidth;
        lp.width = width;
        lp.height = ViewGroup.LayoutParams.WRAP_CONTENT;
        lp.gravity = Gravity.BOTTOM;
        getWindow().setAttributes(lp);

        initView();
    }

    private void initView() {
        tvTakePhoto = (TextView) findViewById(Rx.id.kg_tv_take_photo);
        tvAlbum = (TextView) findViewById(Rx.id.kg_tv_album);
        tvCancel = (TextView) findViewById(Rx.id.kg_tv_cancel);
        tvTakePhoto.setOnClickListener(new View.OnClickListener() {

            @Override
            public void onClick(View v) {
                if (onTakePhotoListener != null) {
                    onTakePhotoListener.onClick(v);
                }

            }
        });
        tvAlbum.setOnClickListener(new View.OnClickListener() {

            @Override
            public void onClick(View v) {
                if (onAlbumListener != null) {
                    onAlbumListener.onClick(v);
                }
            }
        });
        tvCancel.setOnClickListener(new View.OnClickListener() {

            @Override
            public void onClick(View v) {
                if (onCancelModifyListener != null) {
                    onCancelModifyListener.onClick(v);
                }
            }
        });

    }

    public void setOnTakePhotoListener(View.OnClickListener onTakePhotoListener) {
        this.onTakePhotoListener = onTakePhotoListener;
    }

    public void setOnCancelModifyListener(View.OnClickListener onCancelModifyListener) {
        this.onCancelModifyListener = onCancelModifyListener;
    }

    public void setOnAlbumListener(View.OnClickListener onAlbumListener) {
        this.onAlbumListener = onAlbumListener;
    }
}
